package com.erp.controller.purchaseController;

import com.erp.pojo.DepotHead;
import com.erp.service.purchaseService.DepotHeadInService;
import com.erp.utils.Msg;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.Date;

@Controller
@RequestMapping("/depothead")
public class PurchaseInController {

    @Autowired
    private DepotHeadInService depotHeadInService;
    @RequestMapping("/select")
    @ResponseBody
    public Msg selectAll(@RequestParam(value="page",defaultValue = "1")Integer page,
                         @RequestParam(value="limit",defaultValue = "10")Integer limit,
                         @RequestParam(value="number",defaultValue = "") String number,
                         @RequestParam(value="operpersonname",defaultValue = "")String operpersonname,
                         Date billTimeBefore,
                         Date billTimeBack){
        try {
            operpersonname = new String(operpersonname.getBytes("iso-8859-1"), "UTF-8");
        }catch (Exception e){ }
        /*检查是否为条件查询*/
        Msg msg = depotHeadInService.getAllDep(page,limit,number,operpersonname,billTimeBefore,billTimeBack);
        return  msg;
    }

    @PostMapping("/insert")
    public String insertDepotHead(DepotHead depotHead){
        System.out.println("depothead insert");
        System.out.println(depotHead);
        depotHeadInService.addDepotHead(depotHead);
        return "插入成功";
    }
    @RequestMapping("/delete")
    public String deleteDepothead(Long id){
        System.out.println("delete");
        System.out.println(id);
        depotHeadInService.deleteDepoetHead(id);
        return "删除成功";
    }
}
